package com.gs.synedocket.model;


import com.gs.synedocket.callback.Callback;
import com.gs.synedocket.model.listener.OnResultListener;
import com.gs.synedocket.util.OKHttpUtil;

import java.lang.reflect.Type;

public class LoginModel {
    public void login(Object bean, final OnResultListener onResultListener, Type typeOfT) {
        OKHttpUtil.getInstance().postAsync(OKHttpUtil.NET_URL + "/api/users/login", bean, new Callback() {
            @Override
            public void onSuccess(Object obj) {
                onResultListener.onSuccess(obj);
            }

            @Override
            public void onFailed(Exception e) {
                onResultListener.onFails(e);
            }
        }, typeOfT);
    }

    public void getKey( final OnResultListener onResultListener, Type typeOfT) {
        OKHttpUtil.getInstance().getAsync(OKHttpUtil.NET_URL + "/api/users/zvuhvibgljsv", new Callback() {
            @Override
            public void onSuccess(Object obj) {
                onResultListener.onSuccess(obj);
            }

            @Override
            public void onFailed(Exception e) {
                onResultListener.onFails(e);
            }
        }, typeOfT);
    }

    public void reset(String userName, final OnResultListener onResultListener, Type typeofT){
        OKHttpUtil.getInstance().getAsync(OKHttpUtil.NET_URL + "/api/users/forgotPwd?userName="+userName,
                new Callback() {
                    @Override
                    public void onSuccess(Object obj) {
                        onResultListener.onSuccess(obj);
                    }

                    @Override
                    public void onFailed(Exception e) {
                        onResultListener.onFails(e);
                    }
                },typeofT);
    }
}
